package com.example.team.controller;

import com.example.team.entity.Role;
import com.example.team.service.IRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 作者：代志雄
 * 2023年10月31日22点54分
 */
@RestController
@Api(tags = "角色管理")
public class RoleController {
    @Autowired
    private IRoleService roleService;

    @ApiOperation(value = "添加角色类型",
            notes = "成功返回1")
    @RequestMapping(value="/insertRole",method = {RequestMethod.GET})
	public int insertRole(Role role){
        return roleService.insertRole(role);
    }

    @ApiOperation(value = "删除角色类型",
            notes = "成功返回1")
    @RequestMapping(value="/deleteRole",method = {RequestMethod.GET})
	public int deleteRole(int id){
        Role role=new Role();
        role.setRoleId(id);
        return roleService.deleteRole(role);
    }

    @ApiOperation(value = "修改角色类型信息",
            notes = "成功返回1")
    @RequestMapping(value="/updateRole",method = {RequestMethod.GET})
	public int updateRole(Role role){
        return roleService.updateRole(role);
    }

    @ApiOperation(value = "查询所有角色类型信息",
            notes = "成功返回Json")
    @RequestMapping(value="/getAllRole",method = {RequestMethod.GET})
	public List<Role> getAllRole(String name){
        Role role=new Role();
        role.setRoleName(name);
        return roleService.getAllRole(role);
    }

    @ApiOperation(value = "查询角色类型信息",
            notes = "成功返回Json")
    @RequestMapping(value="/getRole",method = {RequestMethod.GET})
	public Role getRole(String name){
        Role role=new Role();
        role.setRoleName(name);
        return roleService.getRole(role);
    }
}
